package Test_0709;

import com.sun.security.jgss.GSSUtil;

import java.util.Arrays;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-07-09
 */
public class Test_0709 {
    public static void main(String[] args) {
        int[] array=new int[]{1,2,3};
        int[] array1=new int[]{4,5,6};
        for(int y:array){
            System.out.print(y+" ");
        }
        System.out.println();
        array=array1;
        for(int y:array){
            System.out.print(y+" ");
        }
        array[0]=9;
        System.out.println();
        System.out.println(array[0]);
        System.out.println(array1[0]);
    }
    public static void main6(String[] args) {
        int[] array=new int[]{1,2,3};
        System.out.println(array[0]);//1
        System.out.println(array[1]);//2
        System.out.println(array[2]);//3

        System.out.println("=======");
        int j=0;
        while(j<array.length){
            System.out.print(array[j]+" ");
            j++;
        }
        System.out.println();
        System.out.println("=======");
        j=0;
        do{
            System.out.print(array[j]+" ");
            j++;
        }while(j<array.length);
        System.out.println();
        System.out.println("=======");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();
        System.out.println("=======");
        for(int y:array){
            System.out.print(y+" ");
        }
        String ret= Arrays.toString(array);
        System.out.println(ret);//[1,2,3]
    }
    public static void main5(String[] args) {
        int[] arrary4;
       // arrary4={1,2,3};//错误，对数组的初始化要在数组定义的时候
        int[] arrary={1,2,3};
        int[] arrary1=new int[3];//与上面一个没有区别，表述可以容纳三个整形类型的元素，默认值都为0
       // int[] arrary2=new double[]{1,2,3};//静态初始化时，T数组元素类型要对应相同
        //int[] arrary2=new int[]{1.0,2.0,3};//静态初始化时，T数组元素的类型要与{}对应相同
        int[] arrary5={1,2,3};//静态初始化时，前面的new T[]可以省略
       // int[] arrary3=new int[3]{1,2,3};
        //错误示范，不能即静态又动态初始化，也就是不能即指定数据个数又指定数据具体内容

        int[] arrary6;
        arrary6=new int[6];
        int[] arrary7;
        arrary7=new int[]{1,2,3};
        //int[] arrary4;
        //arrary4={1,2,3};//分两步初始化的时候，不可以省略new T[]
    }
    //1.2个数相同，类型不同
    public static int add(int a,int b)
    {
        return a+b;
    }
    public static double add(double a,double b)
    {
        return a+b;
    }
    public static int add(int a,short b){
        return a+b;
    }
    //1.3类型相同，个数不同
    public static int add(int a,int b,int c){
        return a+b+c;
    }
    //3,4类型顺序不同
    public static int add(int a,short b,int c){
        return a+b+c;
    }
    public static int add(int a,int c,short b){
        return a+b+c;
    }
    public static void main4(String[] args) {
        int a,b,c;
        int ret=0;
        a=10;
        b=20;
        c=30;
        ret=add(a,b);
        System.out.println(ret);
        ret=add(a,b,c);
        System.out.println(ret);
    }
    public static int xj(int a){
        int ret=0;
        for (int i = 1; i <=a; i++) {
            ret+=jc(i);
        }
        return ret;
    }

    public static int jc(int a){
        int sum=1;
        while(a!=0){
            sum*=a;
            a--;
        }
        return sum;
    }
    public static int add1(int x,int y){
        //x,y是形参
        return x+y;
    }
    public static void main3(String[] args) {
        int a=2;
        int b=3;
        int ret=0;
        ret=add1(a,b);//a,b是实参
        add1(1,2);//1,2是实参
    }
    //计算 1! + 2! + 3! + 4! + 5!
    public static void main2(String[] args) {
        int ret=0;
        int a=5;
        ret =xj(a);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        System.out.println("未调用");
        int a=3;
        int sum=jc(a);
        System.out.println(sum);
    }


}
